<p id="notice"><%= notice %></p>
<div id="user_account">
  <h1>User details</h1>
  <%= link_to "Go back to USERS", users_path %>
  <p style="margin-left:48em">Click to edit</p>
  <table>
    <tr>
      <td>Name <a id="editme" href="#">(edit me)</a></td>
      <td id="name">
        <%= best_in_place @user, :name, as: :input, :activator => "#editme" %>
      </td>
    </tr>
    <tr>
      <td>Last Name</td>
      <td id="last_name">
        <%= best_in_place @user, :last_name, place_holder: 'Nothing to show' %>
      </td>
    </tr>
    <tr>
      <td>Height</td>
      <td id="height">
        <%= best_in_place @user, :height, as: :select, :collection => height_collection, :raw => true %>
      </td>
    </tr>
    <tr>
      <td>Email</td>
      <td id="email">
        <%= best_in_place @user, :email %>
      </td>
    </tr>
    <tr>
      <td>Birth date</td>
      <td id="birth_date">
        <%= best_in_place @user, :birth_date, as: :date %>
      </td>
    </tr>
    <tr>
      <td>Address</td>
      <td id="address">
        <%= best_in_place @user, :address, :display_as => :address_format %>
      </td>
    </tr>
    <tr>
      <td>ZIP</td>
      <td id="zip">
        <%= best_in_place @user, :zip, :display_as => :zip_format %>
      </td>
    </tr>
    <tr>
      <td>Country</td>
      <td id="country">
        <%= best_in_place @user, :country, as: :select, :collection => @countries, :inner_class => :some_class %>
      </td>
    </tr>
    <tr>
      <td>Receive newsletter? (default display)</td>
      <td id="receive_email_default">
        <%= best_in_place @user, :receive_email_default, as: :checkbox %>
      </td>
    </tr>
    <tr>
      <td>Receive newsletter?</td>
      <td id="receive_email">
        <%= best_in_place @user, :receive_email, as: :checkbox, collection: ['No thanks', 'Yes of course'] %>
      </td>
    </tr>
    <tr>
      <td>Receive newsletter (image)?</td>
      <td id="receive_email_image">
        <%= best_in_place @user, :receive_email_image, as: :checkbox, :collection => {'false' => image_tag('no.png'), 'true' => image_tag('yes.png')} %>
      </td>
    </tr>
    <tr>
      <td>Favorite color</td>
      <td id="favorite_color">
        <%- opts = {:ok_button => 'Do it!', :cancel_button => 'Nope', :ok_button_class => 'custom-submit other-custom-submit', :cancel_button_class => 'custom-cancel other-custom-cancel'} %>
        <%- opts.delete(:ok_button) if params[:suppress_ok_button] %>
        <%- opts[:place_holder] = "<span class='placeholder'>Click to add your favorite color</span>" %>
        <%= best_in_place @user, :favorite_color, opts %>
      </td>
    </tr>
    <tr>
      <td>Favorite locale</td>
      <td id="favorite_locale">
        <%= best_in_place @user, :favorite_locale, place_holder: 'N/A' %>
      </td>
    </tr>
    <tr>
      <td>Favorite books</td>
      <td id="favorite_books">
        <%- opts = {as: :textarea, :ok_button => 'Save', :cancel_button => 'Cancel'} %>
        <%- opts.delete(:ok_button) if params[:suppress_ok_button] %>
        <%= best_in_place @user, :favorite_books, opts %>
      </td>
    </tr>
    <tr>
      <td>User description</td>
      <td id="description">
        <%= best_in_place @user, :description, as: :textarea, raw: true %>
      </td>
    </tr>
    <tr>
      <td>Simple-formatted user description</td>
      <td id="dw_description">
        <%= best_in_place @user, :description_simple, display_with: :simple_format, as: :textarea %>
      </td>
    </tr>
    <tr>
      <td>Money</td>
      <td id="money">
        <%= best_in_place @user, :money, :display_with => :number_to_currency%>
      </td>
    </tr>
    <tr>
      <td>Money with proc</td>
      <td id="money_proc">
        <%= best_in_place @user, :money_proc, :display_with => lambda { |v| v.blank? ? "No money" : number_to_currency(v) } %>
      </td>
    </tr>
    <tr>
      <td>Money with custom helper</td>
      <td id="money_custom">
        <%= best_in_place @user, :money_custom, :display_with => lambda { |x| bb(x) } %>
      </td>
    </tr>
    <tr>
      <td>Money with value</td>
      <td id="money_value">
        <%= best_in_place @user, :money_value, :display_with => :number_to_currency, value: 'Custom Value' %>
      </td>
    </tr>
    <tr>
      <td>Favorite Movie</td>
      <td id="favorite_movie">
        <%- opts = {:ok_button => 'Do it!', :cancel_button => 'Nope', :use_confirm => false} %>
        <%- opts.delete(:ok_button) if params[:suppress_ok_button] %>
        <%= best_in_place @user, :favorite_movie, opts %>
      </td>
    </tr>
    <tr>
      <td>Zero Field</td>
      <td id="zero_field">
        <%= best_in_place @user, :zero_field, place_holder: 0 %>
      </td>
    </tr>

  </table>
  <br/>
  <hr/>
  <p>Try the <b>features of Best In Place</b>:</p>
  <ul>
    <li>Try giving wrong email values or too short address, inputs to see server errors.</li>
    <li>Click on newsletter to change a boolean value</li>
    <li>Click on country to change the value in a collection of values</li>
    <li>Use the external handler to change the value of the name</li>
    <li>Try making changes inside inputs or textareas and then press the ESC key to recover the old value</li>
  </ul>
  <p>More information on <a href="http://github.com/bernat/best_in_place">github</a> or
    <a href="http://blog.bernatfarrero.com/in-place-editing-with-javascript-jquery-and-rails-3/">bernatfarrero.com</a>.
  </p>

</div>
